<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ include file= "/WEB-INF/inc/common.jsp"%>
<%@ page import="com.zjht.gmcc.bean.provide.ProvideFormat" %>
<%@ page import="com.zjht.gmcc.bean.provide.Provider" %>
<html>
 <%
     String menuid=Menu.ORDER_MANAGE;
     MyJDBC myJDBC=null;
     try{
    	 if(!MySession.ValidSession(request,out,menuid))return;
    	 String s_opinion=request.getParameter("opinion");//考核意见(0-正常,1-异常)
    	 String s_abnormal=request.getParameter("abnormal");//异常类型
    	 String s_score=request.getParameter("score");//考核结果
    	 String s_fileCode=MyFormat.formatStr(request.getParameter("filecode"));//文件号
    	 String s_assessOper=MyFormat.formatStr(request.getParameter("assessoper"));//经办人
    	 String providerSearch=request.getParameter("providercode"); //检索名称
    %>
<head>
<title>新增质量回访</title> 
<script type="text/javascript" src="/js/autoMail/jquery-1.4.4.min.js?l"></script>
<link rel="stylesheet" type="text/css" href="/js/autoMail/autoMail.css"/>
<script type="text/javascript" src="/js/autoMail/autoMail.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="/js/calendar/skins/aqua/theme.css" title="Aqua">
<script src="/js/calendar/calendar.js"></script>
<script src="/js/calendar/lang/calendar-zh-utf8.js"></script>
<script src="/js/calendar/calendar-setup.js"></script>
 <script type="text/javascript">
 $(function() {
		$('#providercode').autoMail({
	       emails:[]
	     });
	});

 
 function mySearch(){
	  if(document.form1.providercode.value==""){
        alert("请输入供应商编号或名称再进行检索！");
        document.form1.providercode.focus();
        return;
	 }else{
	 document.form1.action="addReturnAss.jsp";
    document.form1.submit();
    } 
 }
 function charUpper(){
	 if(window.event.keyCode>=97&&window.event.keyCode<=122){
			window.event.keyCode=window.event.keyCode-32;
	}
 }

 function mySubmit(){
	 document.form1.providercode.value
		=document.form1.providercode.value.replace(/(^ *)|( *$)/g, "");
	 if(document.form1.providercode.value==""){
		 alert("请输入供应商编号或名称！");
		 document.form1.providercode.focus();
		 return;
	 }else if(document.form1.providerid.value==""){
		 alert("请您检索供应商后再提交！");
		 return;
	 }else  if(document.form1.filecode.value==""){
         alert("请输入文件号！");
         document.form1.filecode.focus();
         return;
     }else if(document.form1.score.value=="<%=MyConstant.SELECT_FIRST_VALUE%>"){
         alert("请选择考核结果！");
         document.form1.score.focus();
         return;
     }else if($("input[name='opinion']:checked").val()=='1' && $("#abnormal").val()=="<%=MyConstant.SELECT_FIRST_VALUE%>"){
         alert("请选择异常类型！");
         document.form1.abnormal.focus();
         return;
     }else if(document.form1.assessoper.value==""){
         alert("请输入经办人！");
         document.form1.assessoper.focus();
         return;
     }else {
 				var stateVal = document.form1.filecode.value;
 				var url = "/ass/CheckFileCode?state=" + escape(stateVal)+"&filecode="+document.form1.filecode.value;
 				url = encodeURI(encodeURI(url));
 				if (window.XMLHttpRequest) { 
 					req = new XMLHttpRequest(); 
 				}
 				else if (window.ActiveXObject) { 
 					req = new ActiveXObject("Microsoft.XMLHTTP"); 
 				} 		
 				if(req) { 
 					req.open("GET",url, true); 
 					req.onreadystatechange = setFileCode; 
 					req.send(null); 
 				} 
 		   }
 
	     function setFileCode() {
		    if (req.readyState == 4) { 
			  if (req.status == 200) {
				var filecode = req.responseXML.getElementsByTagName("aaa"); 
				var s_filecode = filecode[0].firstChild.data;
				if (s_filecode == "0" ) {
					if( confirm("您确定提交吗？")){
					   document.form1.action="/ass/AddReturnAss";
					   showDiv();
						document.form1.submit();
					}
				} else {
					 alert("文件号：【"+document.form1.filecode.value+"】 已存在，不允许重复添加。请您重新输入!");
					 document.form1.filecode.focus();
					 return;
				}								
			  }
		  }
	     }
 }


 function myReset(){
   if(confirm("您确定重填吗？")){
     document.form1.reset();
   }
 }

 function normalClick(click){
	 var abnormal=document.getElementById("abnormal");
     if(click==0){
       abnormal.options[0].selected=true;
       abnormal.disabled='disabled';
     }else{
        abnormal.disabled=false;
     }
 }
 </script>
  </head>
  <body>
    <form action="" name="form1" method="post">
      <page:applyDecorator name="tip">
        <page:param name="left">新增质量回访</page:param>
        <htdz-tag:ButtonTag value="提 交" onclick="mySubmit()"/>  <htdz-tag:ButtonTag value="重 填" onclick="myReset()"/>
      </page:applyDecorator>
    <div id="mydiv"> 
      <table id="mydetail">
      <%
           String s_providerId="";
           String s_providerTypeId="";//供应商性质
           String s_status=""; //供应商状态
           String s_rangeType="";//省内省外
           String s_orderStatus="";//供应商合同状态
           String s_permitStatus="";//供应商准入状态
           String s_providerName="";//供应商名称
           Provider p = ProvideFormat.getProviderInfo(providerSearch);
           if(!MyFormat.isStrNull(providerSearch)){
        	  if(p!=null){
        		 s_providerId=p.getProviderid();
        		 s_providerName=p.getProvidername();
         	     s_providerTypeId=p.getProvidertype();
         	     s_status=p.getStatus();
         	     s_rangeType=p.getRangetype();
         	     s_orderStatus=p.getOrderstatus();
         	     s_permitStatus=p.getPermitstatus();
                 if(!"1".equals(s_orderStatus) ){
                    out.write( "<script>alert('供应商【"+s_providerName+"】合作已暂停，无法进行质量回访！');window.opener = null; window.open('', '_self');window.close();</script>");
                 }else if("0".equals(s_permitStatus)){
                	 out.write( "<script>alert('供应商【"+s_providerName+"】为非准入，无法进行质量回访！');window.opener = null; window.open('', '_self');window.close();</script>");
                 }
               }else{
            	   out.write("<script>alert('未检索到相应供应商信息,请您重新输入！')</script>");
               }
           }
       %>
      <tr>
         <th>供应商检索：</th>
         <td colspan="3"><input name="providercode" type="text" size="30" id="providercode" value="<%=MyFormat.formatStr(providerSearch) %>" onKeyPress='charUpper();'/> 
         <htdz-tag:ButtonTag value="检 索" onclick="mySearch()" /></td>
       </tr>
       <tr>
         <th>供应商名称：</th>
         <td colspan="3"><%=MyFormat.formatStr(s_providerName) %><input type="hidden" name="providerid" id="providerid" value="<%=s_providerId %>"/></td>
       </tr>
       <tr>
         <th>企业性质：</th>
         <td><%=ProvideFormat.getParameter(s_providerTypeId) %></td>
       </tr>
       <tr>  
         <th>当前状态：</th>
         <td><%=ProvideFormat.getProStatus(s_status,s_rangeType,s_orderStatus,s_permitStatus) %></td>
       </tr>
      <tr>
        <th>文件号：</th>
        <td><input type="text" name="filecode" id="filecode" size="30" value="<%=s_fileCode %>"/></td>
      </tr>
      <tr>
        <th>考核结果：</th>
        <td><htdz-tag:SelectProvideType name="score" parentid="<%=MyConstant.PARA_SCORE %>" selected="<%=s_score %>" firstoption="请选择"/></td>
      </tr>
      <tr>
     
        <th>处理意见：</th>
        <td><input type="radio" name="opinion" id="opinion" value="0" checked="true" onclick="normalClick(0)" <%="0".equals(s_opinion)?"checked":"" %> >正常 
            <input type="radio" name="opinion" id="opinion" value="1" onclick="normalClick(1)" >异常<htdz-tag:SelectProvideType name="abnormal" firstoption="请选择" parentid="<%=MyConstant.PARA_OPINION_ABNORMAL %>" selected="<%=s_abnormal %>" disabled="TRUE"/></td>
      </tr>
      <tr>
        <th>考核时间：</th>
        <td><htdz-tag:DateTag name="assessdate" date="TODAY"/></td>
      </tr>
      <tr>
        <th>经办人：</th>
        <td><input name="assessoper" type="text" id="assessoper" size="30" value="<%=s_assessOper %>"/></td>
      </tr>
      <tr>
        <th>备注说明：</th>
        <td><htdz-tag:TextAreaTag name="memo" maxlength="100"/></td>
      </tr>
      </table>
    </div>
  </form>
</body>
  <%
	} catch (Exception e) {
		e.printStackTrace();
		MySession.expAlert(request, out, menuid);
	} finally {
		MyJDBC.close(myJDBC);
	}
%>
</html>
